Skip to content

feat(web): quick-config controls on the config page (#1748) - #1784

Merged
ranxianglei merged 5 commits into
masterfrom
2026-10-05_web-quick-config
Oct 1, 2026
Merged

ranxianglei merged 5 commits into
masterfrom
2026-10-05_web-quick-config

Conversation

@ranxianglei

@ranxianglei ranxianglei commented Sep 30, 2026 •

Copy link
Copy Markdown
Owner

Summary (#1748)

Quick-config card above the raw JSON editor on the config page: controlled widgets for high-frequency fields. Single draft model — controls edit an in-memory draft and serialize live back into #cfg-file-edit; the single Save reuses the existing PUT /__bili/config {file} full-file channel; all controls disable when the file is unparseable. Pure frontend change (src/web/page.ts, src/web/client.ts, src/web/i18n.ts); no wire/message-shape, persistence, or config-schema change.

Config surface: none

Only EXISTING FileConfig fields are exposed — zero new sections/keys/semantics:

  • debug, passthrough (top-level bool toggles)
  • compress.promptPack (select: default / lean / unknown values pass through; picking default deletes the key instead of writing it)
  • compress.nudgeGrowthTokens (number, ±5000 steppers; warning lines below 20000 / above 100000; value == 50000 deletes the key to keep the file clean)
  • compress.preserveRecentMessages (prefilled with kernel default 5; ==5 or cleared deletes the key)
  • protectedTools (comma-separated, * globs, e.g. skill, skill_*; empty deletes the key)
  • mitm.domains (comma-separated; clearing removes the whole mitm block)

The ccr field is deliberately NOT exposed (immature feature, off by default — still editable via advanced JSON). All "default" states delete keys rather than writing equivalent values, so the on-disk file stays minimal.

Token-cost copy is MEASURED, not estimated (local sglang, qwen tokenizer, usage.prompt_tokens): defaultPrompts 12024 chars = 2855 tok; leanPack full surface 6279 chars = 1403 tok; shared base tool descriptions 1356 chars = 298 tok. UI shows "≈2,900+" / "≈1,400".

Pre-flight (rebased onto origin/master @ 023b851)

feat: — human merge per repo convention. Fixes #1748

@github-actions

github-actions Bot commented Sep 30, 2026 •

Copy link
Copy Markdown
Contributor

📦 Built Package Artifact

Branch: 2026-10-05_web-quick-config (4fdfb6f)

Option A — Install this exact build (recommended)

npm install -g billion-context@0.0.1789-pr.1784.a626d95

This exact version is immutable and reproducible. The rolling pr tag tracks the newest test build across all PRs.

Option B — Download artifact

  1. Download the artifact from the Actions run
  2. Extract the tarball and install:
tar xzf billion-context-pr1784.tgz
npm install -g package

Install instructions are refreshed on each push.

@ranxianglei

Copy link
Copy Markdown
Owner Author

🤖 Powered by ework · qwen3.8-27b

[bot] 🏷 Reviewing PR #1784 (feat(web): quick-config controls, #1748) now. Plan: pull the branch, verify the code against the original issue's direction, walk the regression surface of src/web/* + the config PUT channel, check CI status on the head, then report with the structured seven questions. First pass expected shortly.

@ranxianglei

Copy link
Copy Markdown
Owner Author

🤖 Powered by ework · qwen3.8-27b

[bot] 🏷 ## Review 结论 — PR #1784 (feat(web): quick-config controls, #1748)

核验事实

  • head 371dcd8f,base = origin/master(834f7d14),无需 rebase;单 commit,diff 仅 3 个前端文件:src/web/client.ts +192/−1、src/web/i18n.ts +40/−2、src/web/page.ts +5。
  • CI 在 head 上 12/12 全绿(含全部 e2e lane、hermetic registry e2e、build-artifact)。
  • 本地复跑:typecheck clean;tests/web-i18n.test.ts 6/6 通过(catalog 双向键检查、无死键、渲染页漂移、client 语法)。

1. 是什么问题
#1748 要求 web 配置页把高频配置项按钮化、同时保留原始 JSON 编辑器;本 PR 在 JSON 编辑器上方实现了一张 quick-config 卡片(debug/passthrough 开关、promptPack 选择、nudgeGrowthTokens 步进器、preserveRecentMessages、protectedTools、mitm.domains)。

2. 什么原因导致的
功能请求,无缺陷根因。设计动机:控件与原始编辑器共享单一内存 draft、改动实时序列化回编辑器、复用既有 PUT /__bili/config {file} 全文件通道、零新配置面;所有"默认值"状态删键而非写等价值,保持磁盘文件最小化。

3. 怎么修复的
单 draft 模型:hydrateQuickConfig() 解析编辑器内容建 draft,每个控件 handler 改 draft 后整体序列化回 #cfg-file-edit;一个 Save(save-quick)与既有 save-file 走同一 {file: raw} 通道;文件不可解析时整卡隐藏、save-quick 禁用。语义逐项核对过:pack 选 default 删键;未知 pack 名透传为自定义选项(服务端 compress-settings.ts:179 会 warn+回落 default surface,与 UI 提示一致);nudge ==50000 删键——与 kernel flat 50000 带(growthFloor==growthCap)精确一致;prm 预填 kernel 默认 5(acp-kernel dist index.js:432 确认)、==5/清空删键;token 文案(i18n "≈2,900+" / "≈1,400")与 PR 描述一致。ccr 确实未暴露。

4. 是否有回归问题
审过的既有行为及结论:

  • raw JSON 编辑器 + save-file 按钮:代码未动,行为保持;
  • PUT /__bili/config {file} 通道:服务端零改动;save-quick 复用同一 payload 形状与同一客户端校验(parse + 非对象拒绝);
  • 配置解析/校验(src/config.ts)、wire/message-shape、持久化:零 diff;
  • i18n catalog:+18 键 zh/en 对称,双向测试通过;cfg.file_desc 双语同步改文案(有意——可视化编辑已存在)。
    → 既有行为无破坏。但本 PR 新代码引入 1 个会话内隐患 + 2 个小问题:
  • ⚠️ 主问题(建议合并前修):stale-draft 覆盖。hydrateQuickConfig()(src/web/client.ts:1109)只在页面加载时把编辑器内容解析成 draft 一次;所有控件 handler 都改这个对象并 writeDraft()(:1111)覆写 #cfg-file-edit。先手工编辑 JSON、再碰任何 quick 控件 → 手工编辑被静默覆盖(未保存工作丢失)。边界说明:两个 Save 按钮都读编辑器实时值、配置页无轮询刷新、Save 前不碰磁盘——属会话内缓冲区覆盖,不是磁盘配置静默损坏。建议修法:每次 mutation 前重新解析编辑器当前值(以编辑器为 source of truth),改动量很小。或者 owner 明确接受该取舍。
  • 小①:syncNudge()(:1248)在 hydration 期间立即执行 → 即使零操作,每次进配置页都会 parse/stringify(2空格)重写一次编辑器内容;字节级漂移(重复 JSON 键会在 round-trip 中被静默丢弃)。建议首次真实交互前不 writeDraft。
  • 小②:清空 mitm.domains 走 delete draft.mitm(:1273),连带删掉显式的 mitm.enabled(若曾是 enabled:false → MITM 被静默重新启用)。PR 正文披露了"清空移除整个 mitm 块",但更外科的做法是只删 .domains、保留块内其他键。
  • 测试缺口:本 PR 零新增测试;各字段序列化语义(delete-on-default、逗号切分等)是 WEB_CLIENT 模板串里的内联 DOM JS,现状无法单测。现有 web-i18n 测试只覆盖 catalog 双向性/页面漂移/语法。建议抽纯函数按字段钉住(可作 follow-up)。
  • nits(可选):void ptRow.ctl; 死代码消音器(:1278,dbg 行没有对应写法);plab.htmlFor="quick-pack" 悬空——packSel.id 从未赋值(:1174),点 label 不会聚焦 select;nudge input step="1000"(:1203)与按钮 ±5000 不一致;save-quick handler(:1458)与 save-file(:1468)逐行重复约 10 行,可抽共享 helper。

5. 是否破坏缓存
不涉及——未触碰缓存/重试/增量游标/去重键任何路径;wire 与 prefix-cache 相关代码零 diff。

6. 是否改了设计方向
架构无转向(纯前端,复用既有全文件保存通道)。但需要 owner 拍板一件事:PR #1752(schema-driven 详细表单,响应你 "#1748 里'先提供一个详细版本的配置'"的要求)也针对同一个 #1748 且仍 open,与本 PR 触碰同样 3 个文件的同一片区。本 PR 是"高频子集卡片"路线,#1752 是"全量详细表单"路线,二者不能长期并存——合并本 PR 后 #1752 需关闭或重构(反之亦然)。请定路线。

7. 是否引入了新的配置
无。逐字段对照 FileConfig 核实:debug/passthrough(顶层 bool)、compress.promptPack(string,非空校验 src/config.ts:1578;pack 解析序 project > user > builtin,src/config.ts:241)、compress.nudgeGrowthTokens(>0 时 flatten growthFloor/Cap,compress-settings.ts:282)、compress.preserveRecentMessages(kernel 默认 5)、protectedTools(顶层 string[])、mitm.domains(string[])——全部为既有字段,零新 section/key/语义。


判定:修复后可合。建议作者先修主问题(stale-draft 覆盖,小改动,nits 可顺手同轮处理);若 owner 明确接受该取舍,则现状可合。与 #1752 的关系待 owner 裁决。合并操作由人执行。

@ranxianglei ranxianglei mentioned this pull request Sep 30, 2026
@ranxianglei

Copy link
Copy Markdown
Owner Author

Pre-merge blocker (stale-draft overwrite) fixed in commit e24cbefa — implemented exactly the suggested approach, editor as source of truth:

  • Every quick-control mutation now runs through a commit(mutate) core that re-parses #cfg-file-edit immediately before mutating (freshDraft()), applies the change to the fresh object, then re-serializes — hand-edited JSON is never clobbered by touching a control.
  • If the hand-typed JSON is unparseable at mutation time: the mutation is aborted, the textarea stays byte-untouched, all quick inputs disable, and a red note appears (new i18n pair cfg.q_parse_err); a live input listener re-validates and re-enables as soon as it parses again — no reload needed.
  • After each successful mutation syncAll() re-renders every control's displayed value from the fresh draft, so no control can show a value diverging from what's actually in the JSON.
  • Still config surface: none (only i18n keys added).

Pre-flight on the head: typecheck ✓, build ✓, web tests 21/21 ✓.

Manual A/B to confirm: config page → hand-type "debug": true into the advanced JSON → touch any quick control (e.g. nudge stepper) → the hand edit survives; then break the JSON mid-typing and flip a control → controls pause with the note, textarea untouched.

Sandboxed preview: http://127.0.0.1:39003/__bili/#/config (hard-refresh Ctrl/Cmd+Shift+R).

@ranxianglei

Copy link
Copy Markdown
Owner Author

🤖 Powered by ework · qwen3.8-27b

[bot] 🏷 ## Review 第 2 轮 — e24cbefa (fix: re-parse editor before every quick-control mutation)

核验事实

  • 逐行审了修复 diff:commit(mutate) 核心 + freshDraft() 每次 mutation 前重新解析编辑器——与第 1 轮建议的方案一致。全部 7 个控件 handler 都走 commit(src/web/client.ts:1202/:1205/:1227/:1253/:1292/:1300/:1306);不可解析时 abort、textarea 字节不动、控件禁用 + 红字提示(cfg.q_parse_err 双语对称新增);编辑器 input 监听(:1312)实时重校验、修好即恢复,无需 reload;每次成功 mutation 后 syncAll() 从新 draft 重渲所有控件显示值。无悬空引用(旧 writeDraft 已彻底移除)。
  • 附带收益:第 1 轮小①(进页面即 syncNudge()→序列化重写编辑器、字节漂移)一并消除——hydration 末尾只做 syncAll() 渲染控件值,不再触碰编辑器内容;编辑器的字节在首次真实交互前保持原样。
  • Rebase 到当前 master(be637485):零冲突(master 新增为 release v0.1.176 + dsh-native 修复,与本 PR 的 src/web/* 零重叠);rebased head 上 typecheck clean、web-i18n 套件本地 6/6 通过。
  • CI 在 e24cbefa 上 12/12 全绿。

1. 是什么问题:验证第 1 轮的 pre-merge blocker(stale-draft 覆盖:手工编辑 JSON 后碰任何 quick 控件会被静默覆盖)。

2. 什么原因导致的:根因同第 1 轮——单一 draft 只在页面加载时解析一次,后续 mutation 都改这个陈旧对象再整体序列化。本次从机制上消除:改为「mutation 前即时重解析编辑器 → 改新对象 → 再序列化」。

3. 怎么修复的:commit(mutate) 统一入口,以编辑器为 source of truth;不可解析时拒绝 mutation 并进入暂停态(禁用 + 红字),input 监听实现免 reload 恢复;syncAll() 保证控件显示值与 JSON 实际内容永不漂移。

4. 是否有回归问题:

  • 主问题确认解决;暂停态下点 ± 步进按钮是无害 no-op(commit abort,编辑器不变)。
  • 既有行为(save-file/raw 编辑器、PUT {file} 通道、wire/persistence)仍零 diff,无破坏。
  • 残留(均非阻塞,可作 follow-up):
    • R1(建议顺手加固):freshDraft() 对「合法但顶层非对象」的 JSON(数组/标量)返回 {} 而非 abort——该角落情形下 commit 会只序列化被改字段、丢弃文档其余内容。服务端 Save 本就拒绝非对象,概率极低,但与「永不覆盖」不变量不完全自洽;建议把非对象顶层也按 broken 处理(一行改动)。
    • R2:文件在加载时就不可解析的路径,hydrateQuickConfig() 在挂 input 监听之前提前 return → 此状态下修好 JSON 后控件不会 live 回来(需切页/reload 或任一 loadConfig 触发);与「编辑中途弄坏」路径(能 live 恢复)不对称。建议 early-return 路径也挂监听、并在恢复可解析后重新 hydrate 一次。(加载时的红色 banner + save 按钮禁用由既有 loadConfig 机制承担,行为正确。)
    • R3(nits,沿袭第 1 轮未动):void ptRow.ctl; 死消音器;plab.htmlFor="quick-pack" 悬空(packSel.id 未赋值);nudge input step="1000" 与按钮 ±5000 不一致;save-quick 与 save-file handler 逐行重复;± 按钮未进 qCtrls,暂停期视觉上仍可点(点击无害)。

5. 是否破坏缓存:不涉及。

6. 是否改了设计方向:无。#1752 的关系仍待你拍板(本 PR 高频子集卡片 vs #1752 全量详细表单,同一 issue 不能长期并存)。

7. 是否引入了新的配置:无——本 commit 仅新增一对 i18n 键(cfg.q_parse_err),零配置面变化。


判定:pre-merge blocker 已关闭,可合(R1–R3 可留作 follow-up;若希望我现在直接把 R1/R3 打到 PR 分支上,说一声即可)。合并操作由人执行。

@ranxianglei
ranxianglei merged commit bdc170b into master Oct 1, 2026
12 checks passed
@ranxianglei
ranxianglei deleted the 2026-10-05_web-quick-config branch October 15, 2026 05:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

web页面更改配置,按钮化

1 participant